package com.ldn.basic.enumeration;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 李大牛家的牛 (scafel@163.com) 
 * @createDate 2024/9/18 - 12:44
 * @description ...
 **/
@Schema(description = "系统设置枚举")
@Getter
public enum SystemSettingEnum {

    // 基础设置
    BASIC("BASIC", "基础设置"),
    // 快递选项
    KD("KD", "快递选项"),
    // 短信设置
    SMS("SMS", "短信设置"),
    // 阿里云oss
    ALI_OSS("ALI_OSS", "阿里云oss"),
    // 腾讯云oss
    TX_OSS("TX_OSS", "腾讯云oss"),
    // 七牛云oss
    QN_OSS("QN_OSS", "七牛云oss"),
    // 默认
    UNKNOWN("UNKNOWN", "未知"),
    ;

    private static final Map<String, SystemSettingEnum> codeToEnumMap = new HashMap<>();

    static {
        for (SystemSettingEnum type : SystemSettingEnum.values()) {
            codeToEnumMap.put(type.getCode(), type);
        }
    }

    private final String code;
    /**
     * 自定义描述
     **/
    private final String message;

    SystemSettingEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public static SystemSettingEnum getType(String code) {
        SystemSettingEnum type = codeToEnumMap.get(code.toUpperCase());
        if (type == null) {
            return SystemSettingEnum.UNKNOWN;
        }
        return type;
    }

}
